package com.txw.travel.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.txw.travel.mapper.CategoryMapper;
import com.txw.travel.pojo.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional//add tran
public class CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    public Page<Category> getCategoryList(Integer index, Integer size) {
        return categoryMapper.selectPage(new Page<Category>(index, size), null);
    }

    public List<Category> getCategoryList() {
        return categoryMapper.selectList(null);
    }

    public Category getCategoryById(Integer cid) {
        return categoryMapper.selectById(cid);
    }

    public void insertCategory(Category category) {
        categoryMapper.insert(category);
    }

    public void updateCategory(Category category) {
        categoryMapper.updateById(category);
    }

    public void deleteCategory(Integer cid) {
        categoryMapper.deleteById(cid);
    }
}
